<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css" />
		<link rel="stylesheet" type="text/css" href="../../css/style.css" />
		<link rel="stylesheet" type="text/css" href="../../css/btnplus.css" />
		<style type="text/css">
			html,body { background: #F7F8FA; }
			.certification{ background-color: #fff; margin-bottom: 10px; margin-top:10px;}
			.certification b{ display:block; text-align: center; font-size: 14px; color: #cf4242; font-weight: 400; background-color: #fae2e2; line-height: 18px; padding: 12px 0;}
			.certification > div{ padding: 0 15px;}
			.certification h4,.certification_upload h4{ display: block; font-size: 14px; font-weight: 600; color: #403D3D; line-height: 42px;}
			.certification li{ position: relative;}
			.certification li::after{ position:absolute; content: ""; left: 0; right: -10px; bottom: 0; border-top: 1px #d0d0d0 solid; transform: scaleY(0.5);}
			.certification li:nth-child(1)::after{border:0;}
			.certification li:last-child{border:0;}
			.certification p{ font-size: 15px; color: #202532; font-weight:600; line-height: 52px; height: 52px; overflow: hidden;}
			.certification span{ font-size: 15px; color: #202532; font-weight:600; line-height: 26px; height: 52px; vertical-align: middle; overflow: hidden;}
			
			.certification .imgbg { background-color:#fff; width:96px; height:96px; margin: 0 auto;  }
			.certification div img{ margin: 0 auto; width: 96px; height:96px; object-fit: cover; padding-top: 0px; border-radius:7px;}
			.avatarstr{ text-align: center; font-size: 12px !important; color: #9F9F9F !important; padding-top: 0px; height:32px !important; line-height:35px !important; }
			

			.certification_upload{ padding: 0 15px 10px; background-color: #fff; overflow: hidden;}
			.certification_upload h4{ padding: 5px 0 15px;}
			.certification_upload li{ margin-bottom: 10px; height:200px; border: 0.5px #9F9F9F solid; border-radius: 6px; position: relative; overflow: hidden;}
			.certification_upload div{ padding: 70px 0;}
			.certification_upload div img{ margin: 0 auto; width: 25px;}
			.certification_upload p{ text-align: center; font-size: 12px; color: #9F9F9F; padding-top: 10px; }
			.certification_upload i{ display:none; position:absolute; right: 10px; top: 10px; width: 20px; height: 20px; border-radius: 50%; background-image: url(../../image/img_33.png); background-size: 100% auto; z-index: 3;}
			.certification_upload .img{ display:none; width: 100%; height:200px; object-fit: cover;}
			.certification_upload li.on{ border:0;}
			.certification_upload li.on i{ display:block;}
			.certification_upload li.on div{ display:none;}
			.certification_upload li.on .img{ display:block;}

			.certification_upload .d_btn{ margin: 20px 0;}
			.certification input{ display:block; background-color: transparent; border-radius: 0; border:0; width: 100%; box-sizing: border-box; font-size: 14px; padding: 17px 0; text-align: right; color: #333;}

			.footer{ position: fixed; left: 0; bottom: 0; right: 0; background-color: #000; z-index: 9;}
			.footer .con{ margin: 0 auto; width: 100%; box-sizing: border-box; padding: 0; position: relative;}
			.footer h4{ display:block; line-height: 50px; font-size: 15px; color: #fff; font-weight: normal;}
			.footer .left{ position: absolute; left: 0; top: 0; height: 50px; width: 50px; margin-left: 13px; overflow:hidden;}
			.footer .center {display:block; text-align: center; line-height: 32px;}
			.footer .right{ position: absolute; right: 13px; top: 0; height: 50px;}
			
			.display-none { visibility:hidden; }
		</style>
	</head>
	<body>
		<div class="certification">
			
			<div>
				<h4>个人信息</h4>
				<ul>
					<li>
						<div class="imgbg" tapmode onclick="selpic(0);"> 
							<img src="../../image/img_65.png" id="cardIDthumb0" />
							<input type="hidden" name="cardIDthumb_0" id="cardIDthumb_0" value="" />
						</div>
						<p class="avatarstr">请上传本人真实头像</p>
					</li>
					<li>
						<div class="m_cell_hd"><p>您的姓名</p></div>
						<div class="m_cell_ft m_cell_primary"><input type="text" id="realname" value="" class="limitinput" limit-num="10" placeholder="请输入姓名" /></div>
					</li>
					<li>
						<div class="m_cell_hd m_cell_primary"><p>身份证号</p></div>
						<div class="m_cell_ft m_cell_primary"><input type="text" id="idcard" value="" oninput="inputlimit(this,18);" placeholder="请输入您的身份证号" /></div>
					</li>
				</ul>
			</div>
		</div>
		<div class="certification_upload">
			<h4>请上传本人身份证、行驶证</h4>
			<ul>
				<li tapmode onclick="selpic(1);">
					<i tapmode onclick="delimg(this,1);"></i>
					<div> 
						<img src="../../image/img_32.png" alt="" />
						<p>请上传身份证正面照</p>
					</div>
					<img src="../../image/kong.png" id="cardIDthumb1" class="img"/>
					<input type="hidden" name="cardIDthumb_1" id="cardIDthumb_1" value="" />
				</li>
				<li tapmode onclick="selpic(2);">
					<i tapmode onclick="delimg(this,2);"></i>
					<div> 
						<img src="../../image/img_32.png" alt="" />
						<p>请上传身份证反面照</p>
					</div>
					<img src="../../image/kong.png" id="cardIDthumb2" class="img"/>
					<input type="hidden" name="cardIDthumb_2" id="cardIDthumb_2" value="" />
				</li>
				<li tapmode onclick="selpic(3);">
					<i tapmode onclick="delimg(this,3);"></i>
					<div> 
						<img src="../../image/img_32.png" alt="" />
						<p>请上传手持身份证照片</p>
					</div>
					<img src="../../image/kong.png" id="cardIDthumb3" class="img"/>
					<input type="hidden" name="cardIDthumb_3" id="cardIDthumb_3" value="" />
				</li>
				<li tapmode onclick="selpic(4);">
					<i tapmode onclick="delimg(this,4);"></i>
					<div> 
						<img src="../../image/img_32.png" alt="" />
						<p>请上传行驶证照片</p>
					</div>
					<img src="../../image/kong.png" id="cardIDthumb4" class="img"/>
					<input type="hidden" name="cardIDthumb_4" id="cardIDthumb_4" value="" />
				</li>
			</ul>
			<button class="d_btn" tapmode="btnpress" onclick="reg()" id="login-btn">下一步</button>
		</div>
		<div class="footer display-none">
			<ul class="con">
				<div class="left" tapmode onclick="cancelPost();"><h4>取消</h4></div>
				<div class="center" tapmode onclick="resetImg();"><h4>还原</h4></div>
				<div class="right" tapmode onclick="saveAndPost();"><h4>确定</h4></div>
			</ul>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/app.js"></script>
	<script type="text/javascript" src="../../script/permission.js"></script>
	<script type="text/javascript" src="../../script/md5.js"></script>
	<script type="text/javascript">
		var mobile = '';
		var password = '';
		var regtype = 2;
		var UIInput;
		var keyboardId = 0;//当前键盘ID
		var curImgId = 0;
		var FNImageClip;
		apiready = function() {
			api.parseTapmode();
			mobile = api.pageParam.mobile;
			password = api.pageParam.password;
			regtype = api.pageParam.regtype;
			UIInput = api.require('UIInput');
			//fnInitUIInput();
			FNImageClip = api.require('FNImageClip');
			api.addEventListener({
                name: 'navitembtn'
            }, function(ret, err) {
                if (ret.type == 'left') {
					api.closeWin({
					});
                }
            });
			var flag = false
			var inputs = $api.domAll('.limitinput');
			for (var i = 0; i < inputs.length; i++) {
				inputs[i].oninput = function() {
					var limitnum = $api.attr(this,'limit-num');
					setTimeout(() => {
						if (!flag){
							var len = this.value.length;
							if(this.value.length > limitnum)
							{
								this.value = this.value.substr(0,limitnum);
								len = 50;
							}

						}
					}, 0);
				}
			}
			document.addEventListener('compositionstart', function(e) {
				flag = true;
			});
			document.addEventListener('compositionend', function(e) {
				flag = false;
			});
		}
		function delimg(obj,id) {
			//清楚已选图片
			event.stopPropagation();
			$api.removeCls(obj.parentNode,'on');
			$api.val($api.byId('cardIDthumb_'+id),'');
			$api.byId('cardIDthumb'+id).src = '../../image/kong.png';
		}
		function selpic(id) {
			document.activeElement.blur();
			api.actionSheet({
				cancelTitle: '取消',
				buttons: ['拍照', '从手机相册选择'],
				style: {
					layerColor:'rgba(0,0,0,0.3)',         //遮蔽层颜色，仅支持 rgba颜色，默认值：rgba（0, 0, 0, 0.4）
					itemNormalColor:'#fff',    //选项按钮正常状态背景颜色，支持#000、#000000、rgb、rgba，默认值：#F1F1F1
					itemPressColor:'#f5f5f5',     //选项按钮按下时背景颜色，支持#000、#000000、rgb、rgba，默认值：#E6E6E6
					fontNormalColor:'#333',    //选项按钮正常状态文字颜色，支持#000、#000000、rgb、rgba，默认值：#007AFF
					fontPressColor:'#000',     //选项按钮按下时文字颜色，支持#000、#000000、rgb、rgba，默认值：#0060F0
					titleFontColor:'#000'      //标题文字颜色，支持#000、#000000、rgb、rgba，默认值：#8F8F8F
				}
			}, function(ret, err) {
				if(ret.buttonIndex==1 || ret.buttonIndex==2)
				{
					getPicture(ret.buttonIndex,id);
				}
			});
		}
		function openAlbum() {
			getPicture(2,curImgId);
		}
		function openCamera() {
			getPicture(1,curImgId);
		}
		function getPicture(index,id){
			curImgId = id;
			var perdesc = '相册/本地存储';
			var sourceType = 'library';
			var callbakstr = openAlbum;
            if(index==1){
				var pername = new Array('storage','camera');
				sourceType = 'camera';
				perdesc = '相册/拍照';
				callbakstr = openCamera;
				
				if (api.systemType == "android") {
					if(!confirmPerarr(pername,perdesc,callbakstr)){
						return;
					}
				}
			}
			else
			{
				var pername = 'photos';
				if (api.systemType == "android") {
					if(pername == 'photos')
					{
						pername = 'storage';
					}
					if(!confirmPer(pername,perdesc,callbakstr)){
						return;
					}
				}
			}
			api.getPicture({
				sourceType: sourceType,
				encodingType: 'png',
				mediaValue: 'pic',
				targetWidth: 600,
			}, function(ret, err) {
			// 获取图片数据并处理
				if (ret) {
					var imgSrc = ret.data;
					if (imgSrc != "") {
						if(id == 0) {
							selavatar(imgSrc);//选择图片后裁剪
						}
						else
						{
							uploadImage(imgSrc,id);
						}
					}
				}
			});
		}
		function uploadImage(item,id)
		{
			var imageCachePath = api.cacheDir;
			var picname = randomString(32);
			imgFilter(item,id);
		}
		function randomString(len) {
		　　len = len || 32;
		　　var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';    /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
		　　var maxPos = $chars.length;
		　　var pwd = '';
		　　for (i = 0; i < len; i++) {
		　　　　pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
		　　}
		　　return pwd;
		}
		function imgFilter(item,id) {
			console.log(item+'压缩前路径');
			//压缩图片
			var picname = randomString(32);
			var imageCachePath = api.cacheDir;
			var imageFilter = api.require('imageFilter');
			imageFilter.compress({
				img: item,
				quality : 1,
				scale : 1,
				save : {
					album : false,
					imgPath : imageCachePath,
					imgName : picname + '.jpg'
				}
			},function( ret, err ){        
				if( ret.status ){
					//$api.attr($api.byId('cardIDthumb'+id),'src',imageCachePath + '/' + picname + '.jpg');
					$api.byId('cardIDthumb'+id).src = imageCachePath + '/' + picname + '.jpg';
					if(!$api.hasCls($api.byId('cardIDthumb'+id).parentNode, 'on'))
					{
						$api.addCls($api.byId('cardIDthumb'+id).parentNode, 'on');
					}
					var picurl = $api.attr($api.byId('cardIDthumb'+id),'src');
					var trans = api.require('trans');
					trans.decodeImgToBase64({
						imgPath: picurl
					}, function(ret, err) {
						if (ret.status) {
							//转换成base64后上传
							var paramsObj = {
								base64str: 'data:image/jpeg;base64,'+ret.base64Str
							}
							uponeimg(paramsObj,'cardIDthumb_'+id);
						}
					});

				}else{
					alert( JSON.stringify( err ) );
				}
			});
		}
		function uponeimg(pObj,domid) {
			//上传单张图片
			api.showProgress({
				title: '请稍后...',
				text: '',
				modal: true
			});
			api.ajax({
				url: ApiUrl + '/v1/upimgs',
				method: 'post',
				cache: false,
				timeout: 10,
				headers: {
				},
				data: {
					values: pObj
				}
			}, function(ret, err) {
				api.hideProgress();
				if(domid == 'cardIDthumb_0') {
					FNImageClip.close();
					$api.addCls($api.dom('.footer'),'display-none');
				}
				if (ret) {
					$api.val($api.byId(domid),ret.picurl);
				}
			});
		}
		function reg() {
			hideInput();//收起键盘
			var pername = 'camera';
			var perdesc = '相机/拍照';
			
			if (api.systemType == "android") {
				if(pername == 'photos')
				{
					pername = 'storage';
				}
				if(!confirmPer(pername,perdesc,'')){
					return;
				}
			}
			//
			var realname = $api.val($api.byId('realname')).trim();
			var cardID = $api.val($api.byId('idcard')).trim();
			var cardIDthumb0 = $api.val($api.byId('cardIDthumb_0')).trim();
			var cardIDthumb1 = $api.val($api.byId('cardIDthumb_1')).trim();
			var cardIDthumb2 = $api.val($api.byId('cardIDthumb_2')).trim();
			var cardIDthumb3 = $api.val($api.byId('cardIDthumb_3')).trim();
			var cardIDthumb4 = $api.val($api.byId('cardIDthumb_4')).trim();
			if($api.cssVal($api.byId('login-btn'),'opacity')!=1)
			{
				return false;
			}
			if(cardIDthumb0=="")
			{
				showtoast("warning","请上传真实头像");
				return false;
			}
			if(realname == '')
			{
				showtoast("warning","请填写姓名");
				return false;
			}
			if(cardID == '')
			{
				showtoast("warning","请填写身份证号码");
				return false;
			}
			if(cardIDthumb1=="")
			{
				showtoast("warning","请上传身份证正面照");
				return false;
			}
			if(cardIDthumb2=="")
			{
				showtoast("warning","请上传身份证背面照");
				return false;
			}
			if(cardIDthumb3=="")
			{
				showtoast("warning","请上传手持身份证照");
				return false;
			}
			if(cardIDthumb4=="")
			{
				showtoast("warning","请上传行驶证照片");
				return false;
			}
			
			if(!IdentityCodeValid(cardID))
			{
				showtoast("warning","请填写真实身份证号");
				return false;
			}
			showbtnloading('login-btn');
			var paramsObj = {
				app_key: kAppKey,
				mobile: mobile,
				password: password,
				realname: realname,
				idcard: cardID,
				regtype: regtype,
				usertype: 1,
				cardIDthumb0: cardIDthumb0,
				cardIDthumb1: cardIDthumb1,
				cardIDthumb2: cardIDthumb2,
				cardIDthumb3: cardIDthumb3,
				cardIDthumb4: cardIDthumb4
			}
			var _sign = getSign(paramsObj, kAppKey, kAppSecret);
			paramsObj.signature = _sign;
			console.log(JSON.stringify(paramsObj)+'!!!!!!');
			api.ajax({
				url: ApiUrl + '/v1/token/reg',
				method: 'post',
				data: {
					values: paramsObj
				}
			}, function(ret, err) {
				if (ret) {
					if(regtype == 2) {
						console.log(JSON.stringify(ret));
						var access_token = ret.data.access_token;
						var rongcloud_token = ret.data.client.rongcloud_token;
						var credit = ret.data.client.credit;
						var userjson = {
							access_token : access_token,
							rongcloud_token: rongcloud_token,
							uid: ret.data.client.uid,
							realname: ret.data.client.realname,
							credit: credit,
							avatar: ret.data.client.avatar,
							mobile: ret.data.client.mobile,
							status: ret.data.client.status,
							usertype: ret.data.client.usertype
						};
						api.setPrefs({
							key: 'user_info',
							value: userjson
						}, function(ret, err) {
							//closeWin();
						});
						api.sendEvent({
							//刷新主页相关页面逻辑
							name : 'refreshindex',
							extra : {
								userjson : userjson
							}
						});
						api.sendEvent({
							name : 'updateuser',
							extra : {
								userjson : userjson
							}
						});
						//openAlert();
						checkface(ret.data.client.uid);
					}
					else if(regtype == 3) {
						api.getPrefs({
							key: 'user_info'
						}, function(ret, err) {
							if (ret && ret.value)
							{
								var userinfo = JSON.parse(ret.value);
								userinfo.realname = realname;
								api.setPrefs({
									key: 'user_info',
									value: userinfo
								}, function(ret, err) {
									//closeWin();
								});
								api.sendEvent({
									name : 'updateuser',
									extra : {
										userjson : userinfo
									}
								});
								
								//checkface(ret.data.client.uid);
							}
						});
						openAlert();
						//checkface(ret.data.client.uid,ret.data.client.cardIDthumb3);
					}
				} else {
					console.log(JSON.stringify(err));
					showtoast("warning",err.body.message);
				}
				hidebtnloading('login-btn','下一步');
			});
		}
		function checkface(uid) {
			//人脸识别
			var demo = api.require('baiduFaceLive');
			demo.openFaceDetectView({
				rect: {
					x: 0,
					y: 0,
					w : api.winWidth,
					h : api.winHeight,
				},
			
			}, function(ret, err){
				if(ret.evenType=='success'){
					//由于base64数据量大，请不要用JSON.stringify(ret)调试
					var paramsObj = {
						app_key: kAppKey,
						type: 'addface',
						uid: uid
					}
					var _sign = getSign(paramsObj, kAppKey, kAppSecret);
					paramsObj.base64str = 'data:image/jpeg;base64,'+ret.data.bestImage;
					paramsObj.signature = _sign;
					//console.log(JSON.stringify(paramsObj)+'!!!!!!');
					api.ajax({
						url: ApiUrl + '/v1/aips',
						method: 'post',
						data: {
							values: paramsObj
						}
					}, function(ret, err) {
						if (ret) {
							openAlert();
						} else {
							//验证失败，退出无法登陆
							api.removePrefs({
								key: 'user_info'
							});
							
							toast(err.body.message);

						}
						demo.closeFaceDetectView(function(ret, err){
							//alert(JSON.stringify(ret));
						});
					});
					
					
					
					
				}else if(ret.evenType=='Tips'){
					toast(ret.message);
				}else{
					//api.showtoast("warning",{ msg : JSON.stringify(ret) +"  "+JSON.stringify(err)});
				}
			});
		}
		function openAlert()
		{
			var icon = 'suc.png';
			var title = '身份认证已提交';
			var msg = '请耐心等待审核结果';
			var winname = 'root';
			var btntxt = '进入首页';
			var param = {
				icon: icon,
				title: title,
				msg: msg,
				btntxt: btntxt,
				winname: winname,
			};
			openNavWin('#ddd','noheadmsg_win','../public/noheadmsg_frm.html','身份认证',false,true,false,[],param);
		}
		function hideInput(){
			//隐藏键盘
			document.activeElement.blur();
			//UIInput.closeKeyboard({
				//id: keyboardId
			//});
		}
		function fnInitUIInput(){
			//计算位置
			openUIinput('mobile','请输入您的手机号','number','text');
			openUIinput('vcode','请输入验证码','number','text');
		}
		function openUIinput(domid,placeholder_str,keyboardType,inputType){
			//打开UIinput
			var password = $api.byId(domid);
			var password_rect = $api.offset(password);
			UIInput.open({
				rect: {
					x: password_rect.l,
					y: password_rect.t,
					w: password_rect.w,
					h: password_rect.h -1
				},
				styles: {
					bgColor: '#fff',
					size: 14,
					color: '#000',
					placeholder: {
						color: '#999'
					}
				},
				autoFocus: false,
				maxRows: 1,
				placeholder: placeholder_str,
				keyboardType: keyboardType,
				inputType: inputType,
				fixedOn: api.frameName,
				fixed: false
			}, function(ret) {
				
				if (ret.eventType == 'change') {
					keyboardId = ret.id;
					UIInput.value({
							id: ret.id,
							//msg : '设置输入框的值'
					}, function(ret, err) {
						if (ret) {
							$api.val(password,ret.msg);
						} else {
							//alert(JSON.stringify(err));
						}
					});
				} else {
					//alert(JSON.stringify(ret));
				}
			});
			
		}
		function IdentityCodeValid(code) { 
			var city={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江 ",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北 ",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏 ",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外 "};
            var tip = "";
            var pass= true;

            if(!code || !/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(code)){
                tip = "身份证号格式错误";
                pass = false;
            }

			else if(!city[code.substr(0,2)]){
                tip = "地址编码错误";
                pass = false;
            }
            else{
                //18位身份证需要验证最后一位校验位
                if(code.length == 18){
                    code = code.split('');
                    //∑(ai×Wi)(mod 11)
                    //加权因子
                    var factor = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ];
                    //校验位
                    var parity = [ 1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2 ];
                    var sum = 0;
                    var ai = 0;
                    var wi = 0;
                    for (var i = 0; i < 17; i++)
                    {
                        ai = code[i];
                        wi = factor[i];
                        sum += ai * wi;
                    }
                    var last = parity[sum % 11];
                    if(parity[sum % 11] != code[17]){
                        tip = "校验位错误";
                        pass =false;
                    }
                }
            }
            //if(!pass) alert(tip);
            return pass;
        }
		function selavatar(imgUrl) {
			$api.removeCls($api.dom('.footer'),'display-none');
			FNImageClip.open({
				rect: {
					x: 0,
					y: 0,
					w: api.winWidth,
					h: api.winHeight - document.querySelector('.footer').offsetHeight + api.safeArea.top + 45
				},
				srcPath: imgUrl,
				style: {
					mask: 'rgba(0,0,0,0.3)',
					clip: {
						w: 200,
						h: 200,
						x : (api.frameWidth - 200) / 2,
                        y : (api.frameHeight - 200) / 2,
						borderColor: '#0f0',
						borderWidth: 1,
						appearance: 'rectangle'
					}
				},
				mode: 'image'
			}, function(ret, err) {
				if (ret.status) {
					
					//alert(JSON.stringify(ret));
				} else {
					//alert(JSON.stringify(err));
				}
			});
		}
		function saveAndPost(){
			//裁剪成功开始处理，保存并上传
			
			api.showProgress({
				title: '请稍后...',
				text: '正在上传图片',
				modal: true
			});
			var imageCachePath = api.cacheDir;
			FNImageClip.save({
				destPath: imageCachePath+'/mylogo.png',
				copyToAlbum: false,
				quality: 1
			}, function(ret, err) {
				if (ret) {
					//alert(ret.destPath);
					var trans = api.require('trans');
					trans.decodeImgToBase64({
						imgPath: ret.destPath
					}, function(ret, err) {
						if (ret.status) {
							//转换成base64后上传
							//uploadpic('data:image/jpeg;base64,'+ret.base64Str);
							$api.byId('cardIDthumb0').src = 'data:image/jpeg;base64,'+ret.base64Str;
							var paramsObj = {
								base64str: 'data:image/jpeg;base64,'+ret.base64Str
							}
							uponeimg(paramsObj,'cardIDthumb_0');
						} else {
							api.hideProgress();
							//alert(JSON.stringify(err));
						}
					});
				} else {
					//alert(JSON.stringify(err));
				}
			});
		}
		function cancelPost() {
			$api.addCls($api.dom('.footer'),'display-none');
			FNImageClip.close(); //取消
		}
		function resetImg() {
			FNImageClip.reset(); //还原
		}
	</script>
</html>